package com.engineering.elink.controller;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;

import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import com.engineering.elink.common.ResultType;
import com.engineering.elink.service.AreaService;
import com.engineering.elink.service.CarrerStatusService;
import com.engineering.elink.service.CompanyNatureService;
import com.engineering.elink.service.GuildService;
import com.engineering.elink.service.ProvinceService;
import com.engineering.elink.service.RegionService;
import com.engineering.elink.service.ScaleService;
import com.engineering.elink.service.SexService;
import com.engineering.elink.util.MapConvert;


@RestController
@RequestMapping("/api/selector")
@Api(value = "多选项接口")
public class SelectorController {
	
	@Autowired
	private ScaleService scaleService;
	
	@Autowired
	private GuildService guildService;
	@Autowired
	private CompanyNatureService companyNatureService;
	@Autowired
	private ProvinceService provinceService;
	@Autowired
	private RegionService regionService;
	@Autowired
	private AreaService areaService;
	@Autowired
	private CarrerStatusService carrerStatusService;
	@Autowired
	private SexService sexService;
	
	@RequestMapping(value = "/getScaleList", method = RequestMethod.GET)
	@ApiOperation(value = "获取企业规模列表")
	public Map<String, Object> getScaleList() {
		return MapConvert.getMap(ResultType.SUCCESS, scaleService.getScaleList());
	}
	
	@RequestMapping(value = "/getGuildList", method = RequestMethod.GET)
	@ApiOperation(value = "获取企业行业分类列表")
	public Map<String, Object> getGuildList() {
		return MapConvert.getMap(ResultType.SUCCESS, guildService.getGuildList());
	}
	
	@RequestMapping(value = "/getCompanyNatrueList", method = RequestMethod.GET)
	@ApiOperation(value = "获取企业性质列表")
	public Map<String, Object> getCompanyNatrueList() {
		return MapConvert.getMap(ResultType.SUCCESS, companyNatureService.getCompanyNatureList());
	}
	
	@RequestMapping(value = "/getProvinceList", method = RequestMethod.GET)
	@ApiOperation(value = "获取全部省级信息")
	public Map<String, Object> getProvinceList(){
		return MapConvert.getMap(ResultType.SUCCESS, provinceService.getAllList());
	}
	
	@RequestMapping(value = "/getHotRegionList", method = RequestMethod.GET)
	@ApiOperation(value = "获取热门城市信息")
	public Map<String, Object> getHotRegionList() {
		return MapConvert.getMap(ResultType.SUCCESS, regionService.getHotRegionList());
	}
	
	@RequestMapping(value = "/getRegionListInProvince", method = RequestMethod.GET)
	@ApiOperation(value = "获取省级下城市信息")
	public Map<String, Object> getRegionListInProvince(
			@ApiParam(value = "省级ID", required = true) @RequestParam(value = "provinceId", required = true) Integer provinceId){
		return MapConvert.getMap(ResultType.SUCCESS, regionService.getListByProvinceId(provinceId));
	}
	
	@RequestMapping(value = "/getAreaListInRegionId", method = RequestMethod.GET)
	@ApiOperation(value = "获取城市下区域信息")
	public Map<String, Object> getAreaListInRegionId(
			@ApiParam(value = "行政区ID", required = true) @RequestParam(value = "regionId", required = true) Integer regionId){
		return MapConvert.getMap(ResultType.SUCCESS, areaService.getListByRegionId(regionId));
	}
	
	@RequestMapping(value = "/getCarrerStatusList", method = RequestMethod.GET)
	@ApiOperation(value = "获取职业状态列表")
	public Map<String, Object> getCarrerStatusList(){
		return MapConvert.getMap(ResultType.SUCCESS, carrerStatusService.getCarrerStatusList());
	}
	
	@RequestMapping(value = "/getSexList", method = RequestMethod.GET)
	@ApiOperation(value = "获取性别列表")
	public Map<String, Object> getSexList(){
		return MapConvert.getMap(ResultType.SUCCESS, sexService.getSexList());
	}
	
	@RequestMapping(value = "/getAreaInfo", method = RequestMethod.GET)
	@ApiOperation(value = "根据省市区ID获取省市区的名称",httpMethod="GET")
	public Map<String, Object>getAreaInfo(
			@ApiParam(value = "省ID", required = false,defaultValue="0") 
			@RequestParam(value = "provinceId", required = false,defaultValue="0")int provinceId,
			@ApiParam(value = "市ID", required = false,defaultValue="0") 
			@RequestParam(value = "regionId", required = false,defaultValue="0")int regionId,
			@ApiParam(value = "区ID", required = false,defaultValue="0") 
			@RequestParam(value = "areaId", required = false,defaultValue="0")int areaId){
		return MapConvert.getMap(ResultType.SUCCESS, areaService.getAreaInfo(provinceId,regionId,areaId));
	}

	@RequestMapping(value = "/getInfo", method = RequestMethod.GET)
	@ApiOperation(value = "根据二三级ID获取二三级的名称,学生专业(论文)/感兴趣的类目(国内工程)",httpMethod="GET")
	public Map<String, Object>getInfo(	@ApiParam(value = "二级分类ID", required = false,defaultValue="0") 
	@RequestParam(value = "scId", required = false,defaultValue="0")int scId,
	@ApiParam(value = "三级分类ID", required = false,defaultValue="0") 
	@RequestParam(value = "dcId", required = false,defaultValue="0")int dcId){
		return MapConvert.getMap(ResultType.SUCCESS, areaService.getInfo(scId,dcId));
	}
	
	@RequestMapping(value = "/getHierInfo", method = RequestMethod.GET)
	@ApiOperation(value = "根据职业ID获取职业的名称",httpMethod="GET")
	public Map<String, Object>getHierInfo(	@ApiParam(value = "职业ID", required = false,defaultValue="0") 
	@RequestParam(value = "hierId", required = false,defaultValue="0")int hierId){
		return MapConvert.getMap(ResultType.SUCCESS, areaService.getHierInfo(hierId));
	}
}
